/*  1:   */ package org.jetbrains.jps.model.serialization;
/*  2:   */ 
/*  3:   */

import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.Map;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */ 
/* 13:   */ public class PathMacroUtil
/* 14:   */ {
/* 15:   */   @NonNls
/* 16:   */   public static final String PROJECT_DIR_MACRO_NAME = "PROJECT_DIR";
/* 17:   */   @NonNls
/* 18:   */   public static final String MODULE_DIR_MACRO_NAME = "MODULE_DIR";
/* 19:   */   @NonNls
/* 20:   */   public static final String DIRECTORY_STORE_NAME = ".idea";
/* 21:   */   @NonNls
/* 22:   */   public static final String APPLICATION_HOME_DIR = "APPLICATION_HOME_DIR";
/* 23:   */   @NonNls
/* 24:   */   public static final String APPLICATION_PLUGINS_DIR = "APPLICATION_PLUGINS_DIR";
/* 25:   */   @NonNls
/* 26:   */   public static final String USER_HOME_NAME = "USER_HOME";
/* 27:   */   
/* 28:   */   @Nullable
/* 29:   */   public static String getModuleDir(String paramString)
/* 30:   */   {
/* 31:42 */     Object localObject = new File(paramString).getParentFile();
/* 32:43 */     if (localObject == null) {
/* 33:43 */       return null;
/* 34:   */     }
/* 35:48 */     File localFile = ((File)localObject).getParentFile();
/* 36:49 */     if ((localFile != null) && (((File)localObject).getName().equals(".idea"))) {
/* 37:50 */       localObject = localFile;
/* 38:   */     }
/* 39:52 */     String str = ((File)localObject).getPath();
/* 40:53 */     str = str.replace(File.separatorChar, '/');
/* 41:54 */     if (str.endsWith(":/")) {
/* 42:55 */       str = str.substring(0, str.length() - 1);
/* 43:   */     }
/* 44:57 */     return str;
/* 45:   */   }
/* 46:   */   
/* 47:   */   public static String getUserHomePath()
/* 48:   */   {
/* 49:61 */     return StringUtil.trimEnd(FileUtil.toSystemIndependentName(SystemProperties.getUserHome()), "/");
/* 50:   */   }
/* 51:   */   
/* 52:   */   public static Map<String, String> getGlobalSystemMacros()
/* 53:   */   {
/* 54:65 */     HashMap localHashMap = new HashMap();
/* 55:66 */     localHashMap.put("APPLICATION_HOME_DIR", a());
/* 56:67 */     localHashMap.put("APPLICATION_PLUGINS_DIR", b());
/* 57:68 */     localHashMap.put("USER_HOME", getUserHomePath());
/* 58:69 */     return localHashMap;
/* 59:   */   }
/* 60:   */   
/* 61:   */   private static String a()
/* 62:   */   {
/* 63:73 */     return FileUtil.toSystemIndependentName(PathManager.getHomePath());
/* 64:   */   }
/* 65:   */   
/* 66:   */   private static String b()
/* 67:   */   {
/* 68:77 */     return FileUtil.toSystemIndependentName(PathManager.getPluginsPath());
/* 69:   */   }
/* 70:   */   
/* 71:   */   @Nullable
/* 72:   */   public static String getGlobalSystemMacroValue(String paramString)
/* 73:   */   {
/* 74:82 */     if ("APPLICATION_HOME_DIR".equals(paramString)) {
/* 75:82 */       return a();
/* 76:   */     }
/* 77:83 */     if ("APPLICATION_PLUGINS_DIR".equals(paramString)) {
/* 78:83 */       return b();
/* 79:   */     }
/* 80:84 */     if ("USER_HOME".equals(paramString)) {
/* 81:84 */       return getUserHomePath();
/* 82:   */     }
/* 83:85 */     return null;
/* 84:   */   }
/* 85:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.serialization.PathMacroUtil

 * JD-Core Version:    0.7.0.1

 */